package config

import "github.com/zeromicro/go-zero/rest"

type Config struct {
	rest.RestConf
	Nacos      *NacosConfig
	UserRpc    *RpcConf
	OrderRpc   *RpcConf
	ProductRpc *RpcConf
	XxlConf    *XxlJobConfig
	Redis      *RedisConfig
	Limit      *LimitConfig
	MqConf     *MqConfig
	DtmConf    *DtmConf
	JwtConf    struct {
		AccessSecret string
		IgnoreUrl    []string
	}
}

type DtmConf struct {
	Url string `json:"url"`
}

type MqConfig struct {
	AccessKey  string        `json:"accessKey"`
	SecretKey  string        `json:"secretKey"`
	Namesrv    string        `json:"nameSrv"`
	RetryTimes int           `json:"retryTimes"`
	GroupName  string        `json:"groupName"`
	TopicList  []TopicConfig `json:"topicList"`
}
type TopicConfig struct {
	TopicType int    `json:"topicType"`
	TopicName string `json:"topicName"`
	TopicTag  string `json:"topicTag"`
}

type LimitConfig struct {
	Period int `json:"period"`
	Quota  int `json:"quota"`
}

type RedisConfig struct {
	Host         string `json:"host" yaml:"host"`
	Port         int    `json:"port" yaml:"port"`
	Password     string `json:"password" yaml:"password"`
	DB           int    `json:"db" yaml:"db"`
	MinIdleConns int    `json:"minIdleConns"`
	ReadTimeout  int    `json:"readTimeout"`
	WriteTimeout int    `json:"writeTimeout"`
	PoolSize     int    `json:"poolSize"`
	IdleTimeout  int    `json:"idleTimeout"`
	MaxRetries   int    `json:"maxRetries"`
}

type XxlJobConfig struct {
	ServerAddr  string `json:"serverAddr"`
	AccessToken string `json:"accessToken"`
	RegistryKey string `json:"registryKey"`
}

type RpcConf struct {
	Target string `json:"target"`
}

type NacosConfig struct {
	Addr                 string `json:"addr"`
	DataId               string `json:"dataId"`
	ContextPath          string `json:"contextPath"`
	Port                 uint64 `json:"port" `
	Scheme               string `json:"scheme" `
	Username             string `json:"username" `
	Password             string `json:"password" `
	NamespaceId          string `json:"namespaceId" `
	Group                string `json:"group"`
	TimeoutMs            uint64 `json:"timeoutMs" `
	AppName              string `json:"appName" `
	CacheDir             string `json:"cacheDir" `
	LogDir               string `json:"logDir" `
	LogLevel             string `json:"logLevel" `
	UpdateThreadNum      int    `json:"updateThreadNum" `
	NotLoadCacheAtStart  bool   `json:"notLoadCacheAtStart" `
	UpdateCacheWhenEmpty bool   `json:"updateCacheWhenEmpty"`
}
